﻿using Abp.UI;
using Magicodes.WeChat.SDK.Apis;

namespace Magicodes.WeChat.Application
{
    public static class WeChatExtension
    {
        /// <summary>
        ///     处理WeChat SDK API结果错误
        /// </summary>
        /// <param name="apiResult"></param>
        /// <returns></returns>
        public static T HanderApiResultError<T>(this T apiResult) where T : ApiResult
        {
            if (apiResult.IsSuccess())
                return apiResult;
            throw new UserFriendlyException(apiResult.GetFriendlyMessage());
        }
    }
}